//货柜管理-换货申请
App.util.ns('Client.Apply.Exchange');
App.pages.add((function(){
    var NS = Client.Apply.Exchange;
    var page = new App.Page({
        name: 'client/apply/exchange/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-window-restore"></i>',
            content: '货柜管理'
        }, {
            content: '换货申请'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/client/apply/exchange',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                columns: [
                    {name: '货柜', width: '150px', value: function(item){
                        return item.cabinet ? item.cabinet.name : '-- --';
                    }},
                    {name: '状态', width: '90px',value: function(item){
                        switch (item.status+'') {
                            case '0':
                                return '未处理';
                            case '1':
                                return '已处理';
                        }
                    }},
                    {name: '申请日期', width: '80px', value: function(item){
                        return App.util.formator.date(item.created_at);
                    }}
                ]
            },
            filter: [
                {type: 'keywords'},
                {type: 'timeRange'},
                {type: 'select', name: 'status', title: '状态', width: '120px', items: [
                    [0, '未处理'],
                    [1, '已处理']
                ]}
            ],
            menu: [
                {
                    type: 'inline',
                    name: '查看',
                    icon: '<i class="fa fa-eye"></i>',
                    floatable: true,
                    permission: 'op:client.apply.exchange.detail',
                    operation: function(dataTable, item){
                        var win = dataTable.wins.get('exchangeApply').show();
                        win.change(item.cabinet, item.goods_info).show();
                    }
                },
                {type: 'inline', permission: 'op:client.apply.exchange.finish', name: '处理完成', operation: {type: 'change', url: 'finish'}, conditions: [['status', '0']]},
                {parent: 'drop', permission: 'op:client.apply.exchange.delete'},
                {type: 'multi', name: '状态', openable: true, permission: 'op:client.apply.exchange.multiFinish', items: [{
                        type: 'multi', permission: 'op:client.apply.exchange.multiOnline', name: '处理完成', operation: {
                        type: 'change', url: 'multiFinish', confirm: true
                    }}] 
                },
                {parent: 'multiDrop', permission: 'op:client.apply.exchange.multiDelete'},
                {parent: 'oplog', permission: 'op:client.apply.exchange.getOpLogs'}
            ],
            after: function(dataTable){
                dataTable.wins.add(new NS.ExchangeApply(dataTable), 'exchangeApply');
            }
        });
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面显示
    page.showStack.add('dataTable', function(){
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());